Skip to content

Support font color tags in subtitles#791

Open
gabeluci wants to merge 3 commits intojellyfin:masterfrom
gabeluci:subtitle-font-color
Open

Support font color tags in subtitles#791
gabeluci wants to merge 3 commits intojellyfin:masterfrom
gabeluci:subtitle-font-color

Conversation

@gabeluci
Copy link
Contributor

Changes

  1. Add support for font color tags
  2. Center-aligned subtitles. This was a one-liner (line 235). Just about every other implementation of subtitles is center-aligned so I figured this was just missed along the way?

Notes on the font color tags:

  • Various formats of the color are supported, like "#000000", "#000", "rgb(0,0,0)", and CSS color names (pulled from here). Spaces anywhere in the tag don't matter.
  • Malformed font tags ("color" attribute missing, or color is not in an expected format) are ignored. This is important to validate because MultiStyleLabel.drawingStyles will ignore the entire array you give it if any of the data is bad.
  • Nested tags are supported. It doesn't make much sense to nest one font tag inside another font tag, but it will make sense for bold and italic, so I dealt with it now. It was tricky since MultiStyleLabel doesn't support nesting styles.

I've attached a short sample video (just stock footage and sound) with a subtitle file that shows the various formats it handles (or ignores). I put some italics and bold tags in there for later use.

Sample.zip

Issues

Partially fixes #787

@gabeluci gabeluci requested a review from a team as a code owner March 17, 2026 03:07
@gabeluci
Copy link
Contributor Author

gabeluci commented Mar 21, 2026

Ok, I see now why the original developer used a separate label for each line.

With one label, if you have a short line and a long line, the background will extend on the short line to the full width of the long line. It's one big rectangle.

If each line is its own label, then the background is only behind the text.

I'll work on this some more so that behaviour doesn't change.

Edit: Actually, this isn't true. It was the same with the custom subtitles in 3.1.7 (the background is one big rectangle and not only behind the text). Maybe there's a way to change it, but that can be a separate change.

@gabeluci gabeluci force-pushed the subtitle-font-color branch 2 times, most recently from b8c7613 to f4c6ffe Compare March 24, 2026 03:30
@gabeluci
Copy link
Contributor Author

Thanks for reviewing. I've made those updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support text formatting in subtitles

2 participants